package com.td.framework.webmanager.page;
/**
 * 分页类
 * @author 天地软件
 * 
 */
public class Page {
      private int curentPage;  // 当前页数
      private int totalRows;   // 总共行数
      private int pageSize = 10;  //每页显示的行数
      private int totalPages;  //总共页数
      private int startRow;  //开始行数
      
      public Page(){
    	  
      }
      /**
       * 更具中条数确定分页情况
       * @param 总页数
       */
      public Page(int totalRows,int curentPage,int pagesize){
    	 this.totalRows = totalRows;
    	 int pages;
    	 if(pagesize > 0){
    		 this.pageSize = pagesize;
    	 }
    	 totalPages = this.totalPages/this.pageSize;
		 pages = this.totalRows%this.pageSize;
		 if(pages > 0){
			 totalPages = this.totalRows/this.pageSize+1;
		 }
    	 this.startRow = 0;
    	 this.curentPage = curentPage;
      }
      
     /**
      * 首页
      */
     public void first(){
    	this.curentPage = 1; 
    	this.startRow = 0;
     }
     /**
      *  上一页
      */
     public void previous(){ 
    	 this.curentPage--;
        this.startRow = (this.curentPage-1)*pageSize;        
     }
     /**
      * 下一页
      */
     public void next(){
    	 this.curentPage++;
    	this.startRow = (this.curentPage-1)*pageSize;
    	
     }
     /**
      * 最后一页
      */
    public void last(){
    	this.curentPage = this.totalPages;
    	this.startRow = (this.curentPage-1)*pageSize;
    }
    /**
     * go
     */
    public void go(){
        if(this.curentPage >= this.totalPages){
        	last();
        }else{
           this.startRow = (this.curentPage-1)*pageSize;	
        }
    }
    
	public int getCurentPage() {
		return curentPage;
	}
	public void setCurentPage(int curentPage) {
		this.curentPage = curentPage;
	}
	public int getTotalRows() {
		return totalRows;
	}
	public void setTotalRows(int totalRows) {
		this.totalRows = totalRows;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getTotalPages() {
		return totalPages;
	}
	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}
	public int getStartRow() {
		return startRow;
	}
	public void setStartRow(int startRow) {
		this.startRow = startRow;
	}
    
    
    
}
